<template>
    <view class="ad-banner">
      <swiper class="banner-swiper" circular autoplay interval="3000" duration="500" indicator-dots indicator-color="rgba(255, 255, 255, 0.6)" indicator-active-color="#ffffff">
        <swiper-item v-for="(item, index) in bannerList" :key="index" @click="handleBannerClick(item)">
          <view class="banner-item" :style="{ backgroundColor: item.bgColor }">
            <view class="banner-title">{{ item.title }}</view>
            <view class="banner-subtitle">{{ item.subtitle }}</view>
          </view>
        </swiper-item>
      </swiper>
    </view>	
  </template>
  
  <script>
  export default {
    name: 'AdBanner',
    data() {
      return {
        bannerList: [
          {
            id: 1,
            title: '医疗会议峰会',
            subtitle: '前沿医疗技术交流',
            bgColor: '#2989d8',
            url: '/pages/conference/index'
          },
          {
            id: 2,
            title: '酒店住宿服务',
            subtitle: '舒适便捷的住宿体验',
            bgColor: '#3b9980',
            url: '/pages/accommodation/index'
          },
          {
            id: 3,
            title: '智慧医疗创新',
            subtitle: '探索医疗科技前沿',
            bgColor: '#d77e4d',
            url: ''
          }
        ]
      }
    },
    methods: {
      handleBannerClick(item) {
        if (item.url) {
          uni.navigateTo({
            url: item.url
          })
        }
      }
    }
  }
  </script>
  
  <style scoped>
  .ad-banner {
    width: 100%;
    border-radius: 8px;
    overflow: hidden;
    margin: 10px 0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  }
  
  .banner-swiper {
    width: 100%;
    height: 140px;
  }
  
  .banner-item {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    padding: 20px;
  }
  
  .banner-title {
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 10px;
    text-align: center;
  }
  
  .banner-subtitle {
    font-size: 14px;
    opacity: 0.9;
    text-align: center;
  }
  </style> 